﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QLSV
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int tieuthu = 0;
        int tong = 0;
        String ten=null;
        private void btnTinh_Click(object sender, EventArgs e)
        {

            int a = cboTen.SelectedIndex;
            if (a < 0)
                return;
            if (txtSoCu.Text.Length == 0 || txtSoMoi.Text.Length == 0)
                return;
            ten = cboTen.SelectedItem.ToString();
            int socu = int.Parse(txtSoCu.Text);
            int somoi = int.Parse(txtSoMoi.Text);
            if (socu >= somoi)
                return;
             tieuthu = somoi - socu;
            int trongdm = 0;
            int vuotdm = 0;
            if (tieuthu > 50)
            {
                trongdm = 50;
                vuotdm = tieuthu - 50;
            }
            else
            {
                trongdm = tieuthu;
            }
             tong = trongdm * 500 + vuotdm * 1000;
            txtTrongDM.Text = trongdm.ToString();
            txtVuotDM.Text = vuotdm.ToString();
            txtTieuThu.Text = tieuthu.ToString();
            txtTongTien.Text = tong.ToString();
            
        }



        private void btnThoat_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnIn_Click(object sender, EventArgs e)
        {
            if (ten == null)
                return;
            listbox.Items.Add(ten);
            listbox.Items.Add("Số kw tiêu thụ: " + tieuthu.ToString());
            listbox.Items.Add("Tổng tiền: " + tong.ToString());
            ten = null;
        }
    }
}
